package sa.com.sure.ejtimaa;

import sa.com.sure.ejtimaa.R;
import sa.com.sure.ejtimaa.database.Settings;
import sa.com.sure.ejtimaa.model.SettingInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class SettingActivity extends BaseActivity {
    /** Called when the activity is first created. */
	
	private EditText etWebServiceURL = null;
	private String webServiceURL = "";
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setting);
        
        etWebServiceURL = (EditText)findViewById(R.id.etWebServiceURL) ;
        
        etWebServiceURL.setText(Settings.Instance.GetItem("WebServiceURL").GetValue());
        
    }
    
    public void OnSave(View view)  {
    	
    	webServiceURL = etWebServiceURL.getText().toString();   	    
     	    	
    	if( checkValidation())
    	{    	
			SettingInfo item = new SettingInfo("WebServiceURL" , webServiceURL);    	
			Settings.Instance.updateItem(item);    	
			
			Toast.makeText(this, getString(R.string.OperationSuccessfully), Toast.LENGTH_SHORT).show();
    	}
    }
    	
    private boolean checkValidation(){
        	
    	boolean result = true;
    	
    	if(webServiceURL.length()==0){
    		
    		etWebServiceURL.setError("please enter WebServiceURL");
    		result = false;
    	}
    	     	
    	return result;
    }

}